<template>
  <div class="food-list" v-if="index === 0">
    <van-tree-select v-model:main-active-index="activeIndex" height="88vw" :items="items">
      <template #content>
        shangpin
      </template>
    </van-tree-select>

  </div>
  <div v-else>
    {{ foodData.content }}
  </div>
</template>

<script>
import { reactive, toRefs } from 'vue';
export default {
  props: ["index", "foodData"],
  setup(props) {
    let data = reactive({
      activeIndex: 0,
      items: [{ text: "分组1" }, { text: "分组2" }]
    })

    // 初始化数据
    const initData = () => {
      let newArray = []
      props.foodData?.items?.forEach((item, index) => {
        newArray.push({
          text: item.text
        })
      });
      data.items = newArray
    }
    initData()

    return {
      ...toRefs(data)
    }
  }
}
</script>